package be.kdg.netpresentclient;

import java.io.IOException;
import java.rmi.RemoteException;

import javax.swing.JOptionPane;

import be.kdg.netpresent.NetPresentInt;

/**
 * Class that asks the user which presentation he wants to follow by
 * using a message box
 *
 * @autor Timothy Huber, Joris Clevenbergs, Rik verschuren, Wim Van der Wilt
 */
public class ClientFirstChoice {
	private String[] sOptions;
	
	/**
	* Constructor, gets the list of presentation from the server.
	*
	* @param serverObject  interface necessary for getting the list of presentation.
	*/
	public ClientFirstChoice(NetPresentInt serverObject) {
		String[] sObjOptions = null;

		try {
			sObjOptions = serverObject.getPresentationList();
		} catch (RemoteException e) {
			sObjOptions = null;
			e.printStackTrace();
		}

		this.sOptions = sObjOptions;
	}
	
	/**
	* Shows a message box with a drop down menu from which the user selects
	* the presentation he/she wants to follow and gives back the name of the
	* chosen presentation.
	*/
	public String getUserChoice() throws IOException, InterruptedException {
		String sChoice = (String) JOptionPane.showInputDialog(null,
				"Welkom, welke presentatie\nwilt u openen?",
				"Selecteer presentatie", JOptionPane.QUESTION_MESSAGE, null,
				this.sOptions, sOptions[0]);

		return sChoice;
	}
}
